package com.example.makerspace.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.makerspace.domain.CompetitionDO;
import com.example.makerspace.domain.QuestionsCategoryDO;
import com.example.makerspace.domain.QuestionsTypeDO;
import com.example.makerspace.dto.*;
import com.example.makerspace.service.CompetitionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Controller
@ResponseBody
@RequestMapping("/api/competition")
@Slf4j
@Api(tags = "赛题模块")
public class CompetitionController {
    @Resource
    private CompetitionService competitionService;

    @ApiOperation(value="赛题检测接口",notes ="赛题检测说明")
    @PostMapping("/check")
    public Result checkCompetition(HttpServletRequest request,Integer id
    ) {
        return competitionService.checkCompetition(request, id);

    }
    @ApiOperation(value="赛题报名接口",notes ="赛题报名接口说明")
    @PostMapping("/save")
    public  Result saveCompetition(@ModelAttribute CompetitionDTO competitionDTO,String username){
        return  competitionService.save(competitionDTO,username);
    }

    /**
     * 模糊查询
     * @param pageRequest
     * @return
     */
    @ApiOperation(value="赛题模糊查询接口",notes ="赛题模糊查询接口说明")
    @PostMapping("/vagueQuery")
    public IPage<CompetitionDO> vagueQuery(@RequestBody PageRequest pageRequest){
        return  competitionService.selectByCondition(pageRequest);
    }

    /**
     * 指定查询
     * @param pageRequest
     * @return
     */
    @ApiOperation(value="赛题指定查询接口",notes ="赛题指定查询接口说明")
    @PostMapping("/designateQuery")
    public IPage<CompetitionDO> designateQuery(@RequestBody PageRequest pageRequest) {
        return  competitionService.designateQuery(pageRequest);
    }

    /**
     * 赛题变更记录
     * @param request
     * @param competitionId
     * @return
     */
    @ApiOperation(value="赛题变更记录接口",notes ="赛题变更记录接口说明")
    @GetMapping("/competitionChangeRecord")
    public Result competitionChangeRecord(HttpServletRequest request,Integer competitionId) {
        return  competitionService.competitionChangeRecord(request,competitionId);
    }

    /**
     * 展示
     * @return
     */
    @ApiOperation(value="展示赛题变更记录接口",notes ="展示赛题变更记录接口说明")
    @GetMapping("/selectCompetitionChangeRecord")
    public  Result selectCompetitionChangeRecord(Integer competitionId,String username){
        return  competitionService.selectCompetitionChangeRecord(competitionId,username);
    }

    /**
     * (后台)保存赛题
     * @param competitionCategoryDTO
     * @return
     */
    @ApiOperation(value="上传赛题信息接口",notes ="上传赛题信息接口说明")
    @PostMapping("/saveQuestionsCategory")
    public  Result saveQuestionsCategory(@RequestBody CompetitionCategoryDTO competitionCategoryDTO){
        return  competitionService.saveQuestionsCategory(competitionCategoryDTO);
    }

    /**
     * (后台)修改赛题
     * @param competitionCategoryDTO
     * @return
     */
    @ApiOperation(value="修改赛题接口",notes ="修改赛题接口说明")
    @PostMapping("/updateQuestionsCategory")
    public  Result updateQuestionsCategory(@RequestBody CompetitionCategoryDTO competitionCategoryDTO){
        return  competitionService.updateQuestionsCategory(competitionCategoryDTO);
    }

    /**
     * (后台)删除赛题
     * @param competitionCategoryDTO
     * @return
     */

    @ApiOperation(value="删除赛题接口",notes ="删除赛题接口说明")
    @PostMapping("/deleteQuestionsCategory")
    public  Result deleteQuestionsCategory(@RequestBody CompetitionCategoryDTO competitionCategoryDTO){
        return  competitionService.deleteQuestionsCategory(competitionCategoryDTO);
    }

    /**
     * 修改赛题标签
     * @param questionsTypeDO
     * @return
     */
    @ApiOperation(value="修改赛题标签",notes ="修改赛题标签说明")
    @PostMapping("/updateQuestionsType")
    public  Result updateQuestionsType(@RequestBody QuestionsTypeDO questionsTypeDO){
        return  competitionService.updateQuestionsType(questionsTypeDO);
    }

    /**
     * 删除赛题标签
     * @param questionsTypeDO
     * @return
     */
    @ApiOperation(value="删除赛题标签",notes ="删除赛题标签说明")
    @PostMapping("/deleteQuestionsType")
    public  Result deleteQuestionsType(@RequestBody QuestionsTypeDO questionsTypeDO){
        return  competitionService.deleteQuestionsType(questionsTypeDO);
    }
    /**
     * 展示赛题分类
     */
    @ApiOperation(value="展示赛题分类",notes ="展示赛题分类说明")
    @GetMapping("/showQuestionsType")
    public  Result showQuestionsType(){
        return  competitionService.showQuestionsType();
    }

    /**
     * 增加赛题分类
     * @param questionsTypeDO
     * @return
     */
    @ApiOperation(value="增加赛题分类",notes ="增加赛题分类说明")
    @PostMapping("/addQuestionsType")
    public  Result addQuestionsType(@RequestBody QuestionsTypeDO questionsTypeDO){
        return  competitionService.addQuestionsType(questionsTypeDO);
    }

    /**
     * 赛题选择状态
     * @param request
     * @param competitionId
     * @return
     */
    @ApiOperation(value="展示用户的赛题选择状态",notes ="展示用户的赛题选择状态说明")
    @GetMapping("/questionsProcessStatus")
    public  Result questionsProcessStatus(HttpServletRequest request,Integer competitionId){
        return  competitionService.questionsProcessStatus(request,competitionId);
    }
}
